package com.jinlia.show.modules.base.system.entity;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.jinlia.show.common.core.entity.BaseEntity;
import com.jinlia.show.modules.base.config.DynamicSchemaConfig;
import com.jinlia.show.modules.base.constant.CouponTypeEnum;
import com.jinlia.show.modules.base.constant.i.IBaseEnum;
import lombok.Data;

import java.math.BigDecimal;
import java.time.LocalDate;

@Data
@TableName(value = "erp_coupon", schema = DynamicSchemaConfig.schema_system)
public class Coupon extends BaseEntity {

    @TableId()
    private Long id;
    /**
     * 优惠券名称
     */
    private String name;
    /**
     * 优惠券类型(折扣,满减,抵用)
     * 1:抵用券，2满减券，3:折扣券
     */
    private Integer couponType;
    @TableField(exist = false)
    private String couponTypeName;
    /**
     * 优惠券面值
     * couponType =1or2 时: 优惠券面值
     * couponType =3 时: 优惠券折扣
     */
    private BigDecimal couponMoney;
    /**
     * 优惠券使用条件
     * couponType =1or2 时:满减条件
     * couponType =3 时:无
     */
    private BigDecimal conditionMoney;
    /**
     * 优惠券有效期（天）
     */
    private Integer validDate;
    /**
     * 优惠券有效期结束
     */
    private LocalDate endDate;
    /**
     * 发放总数量
     */
    private Integer releaseAmount;
    /**
     * 已发放数量
     */
    private Integer releasedAmount;

    public void setCouponType(Integer couponType) {
        this.couponType = couponType;
        this.couponTypeName = IBaseEnum.getLabelByValue(couponType, CouponTypeEnum.class);
    }
}
